#!/usr/bin/python
import sys
import os
import shutil
from readConfig import *

config = None

def get_separator():
    if 'win' in sys.platform:
        separator = '\\'
    else:
        separator = '/'
    return separator

def init():
    global config
    if(config is None):
      config = ReadConfig()
      path = config.find_path("config.ini")
      config.__read__(path)

def get_stock_data_path():
    init()
    stock_path = config.get_stock("path")
    if not os.path.exists(stock_path):
        os.makedirs(stock_path)
    return stock_path

def get_stock_png_path():
    init()
    stock_path = config.get_stock("png_path")
    if not os.path.exists(stock_path):
        os.makedirs(stock_path)
    return stock_path

def get_tdx_export_path():
    init()
    stock_path = config.get_stock("tdx_export_path")
    if not os.path.exists(stock_path):
        os.makedirs(stock_path)
    return stock_path


def mkdir(directory):

    """
    如果directory不存在则创建，如果存在删除该目录下所有内容
    :param directory: 路径
    :return:
    """
    if os.path.exists(directory):
        shutil.rmtree(directory)
    os.makedirs(directory)
